// 导入创建的axios副本
import request from '@/utils/request.js'

// 登录接口API
function authorizationsPost (data) {
  return request({
    method: 'post',
    url: '/v1_0/authorizations',
    data: data
  })
}

// 获取用户信息接口
function userProfile () {
  return request({
    method: 'get',
    url: '/v1_0/user/profile'
    // headers: {
    //   Authorization: `Bearer ${getItem()}`
    // }
  })
}

// 获取频道列表接口
function channels () {
  return request({
    method: 'get',
    url: '/v1_0/channels'
  })
}

// 获取文章列表接口
function mpArticles (data) {
  return request({
    methods: 'get',
    url: '/v1_0/mp/articles',
    // headers: {
    //   Authorization: `Bearer ${getItem()}`
    // }
    params: data
  })
}

// 发表文章/存为草稿接口
function mpArticlesPost (data, draft) {
  return request({
    method: 'post',
    url: '/v1_0/mp/articles',
    data: data,
    params: {
      draft: draft
    }
  })
}

// 删除文章接口
function mpArticlesDelete (id) {
  return request({
    method: 'delete',
    url: '/v1_0/mp/articles/' + id
  })
}

// 点击编辑后获取文章数据的接口
function mpArticlesGet (id) {
  return request({
    url: '/v1_0/mp/articles/' + id
  })
}

function mpArticlesPut (data, draft) {
  return request({
    url: '/v1_0/mp/articles/' + data.id,
    method: 'put',
    params: {
      draft: draft
    },
    data: data
  })
}

// 暴露
export {
  authorizationsPost,
  userProfile,
  channels,
  mpArticles,
  mpArticlesPost,
  mpArticlesDelete,
  mpArticlesGet,
  mpArticlesPut
}
